package pl.edu.agh.mwo.model.dataimport;

import java.io.FileInputStream;
import java.io.InputStream;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Sheet;

public class ExcelFileReader {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		new ExcelFileReader().testRead();
	}
	
	public void testRead() throws Exception {
		InputStream inp = new FileInputStream("res/Zeszyt1.xls");
				
			    HSSFWorkbook wb = new HSSFWorkbook(new POIFSFileSystem(inp));
			    
			    // drukowanie listy zakladek
			    System.out.println("-- Drukuje liste zakladek: -- ");
			    for (int i = 0; i<wb.getNumberOfSheets(); i++) {
			    	System.out.println(wb.getSheetName(i));
			    }
			    
			    // pobranie wierszy w 1szej zakladki
			    Sheet sheet1 = wb.getSheetAt(0);
		    	System.out.println("-- Zawartosc komorki: (0,0) --\n" + sheet1.getRow(0).getCell(0).getStringCellValue());

	}

}
